#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};

vector<vector<int>> zigzagLevelOrder(TreeNode* root) {
    if (root == nullptr)
        return vector<vector<int>>();
    queue<TreeNode*> que;
    vector<vector<int>> ret;
    int level = 1;

    que.push(root);

    while (!que.empty())
    {
        vector<int> tmp;
        int sz = que.size();
        for (int i = 0; i < sz; ++i)
        {
            TreeNode* node = que.front();
            que.pop();
            tmp.push_back(node->val);
            if (node->left != nullptr)
                que.push(node->left);
            if (node->right != nullptr)
                que.push(node->right);
        }
        if (level % 2 == 0)
            reverse(tmp.begin(), tmp.end());
        ret.push_back(tmp);
        ++level;
    }

    return ret;
}

int main()
{

	return 0;
}